<?php $this->pageTitle=Yii::app()->name . ' - '.UserModule::t("Registration");
$this->breadcrumbs=array(
	UserModule::t("Registration"),
);
?>

<h1><?php echo UserModule::t("Registration"); ?></h1>

<?php if(Yii::app()->user->hasFlash('registration')): ?>
<div class="success">
<?php echo Yii::app()->user->getFlash('registration'); ?>
</div>
<?php else: ?>
<div class="span-15">
<div class="form">
<?php $form=$this->beginWidget('UActiveForm', array(
	'id'=>'registration-form',
	'enableAjaxValidation'=>true,
	'disableAjaxValidationAttributes'=>array('RegistrationForm_verifyCode'),
	'clientOptions'=>array(
		'validateOnSubmit'=>true,
	),
	'htmlOptions' => array('enctype'=>'multipart/form-data'),
)); ?>
<table>
	<tr>
		<td colspan="2">
		<p class="note"><?php echo UserModule::t('Fields with <span class="required">*</span> are required.'); ?></p>
		</td>
	</tr>
	<tr>
		<td colspan="2">
                    <?php echo $form->errorSummary(array($model,$profile)); ?>
		</td>		
	</tr>
	<tr>
		<td algin="right">
                    <div align="right">
                        <?php echo $form->labelEx($model,'username'); ?>
                    </div>
		</td>
		<td>
                    <?php echo $form->textField($model,'username'); ?>
                    <?php echo $form->error($model,'username'); ?>
		</td>
	</tr>
	<tr>
		<td>
                    <div align="right"> <?php echo $form->labelEx($model,'password'); ?></div> 
		</td>
		<td>
                    <?php echo $form->passwordField($model,'password'); ?>                    
                    <?php echo $form->error($model,'password'); ?>
		</td>
	</tr>
	<tr>
            <td>
                
            </td>
            <td>    
                <p class="hint">
                <?php echo UserModule::t("Minimal password length 4 symbols."); ?>
                </p>
           </td>
	</tr>
	<tr>
		<td>
                    <div align="right"> <?php echo $form->labelEx($model,'verifyPassword'); ?></div> 
		</td>
		<td>
                    <?php echo $form->passwordField($model,'verifyPassword'); ?>
                    <?php echo $form->error($model,'verifyPassword'); ?>
		</td>
	</tr>
	<tr>
		<td>
                    <div align="right"> <?php echo $form->labelEx($model,'email'); ?></div> 
		</td>
		<td>
                    <?php echo $form->textField($model,'email'); ?>
                    <?php echo $form->error($model,'email'); ?>
		</td>
	</tr>
	<?php 
		$profileFields=Profile::getFields();
		if ($profileFields) {
			foreach($profileFields as $field) {
			?>
	<tr>
		<td>
                    <div align="right"> <?php echo $form->labelEx($profile,$field->varname); ?></div> 
                </td>
		<td>
		<?php 
		if ($widgetEdit = $field->widgetEdit($profile)) {
			echo $widgetEdit;
		} elseif ($field->range) {
			echo $form->dropDownList($profile,$field->varname,Profile::range($field->range));
		} elseif ($field->field_type=="TEXT") {
			echo$form->textArea($profile,$field->varname,array('rows'=>6, 'cols'=>50));
		} else {
			echo $form->textField($profile,$field->varname,array('size'=>$field->field_size,'maxlength'=>(($field->field_size)?$field->field_size:255)));
		}
		 ?>		
                    <?php echo $form->error($profile,$field->varname); ?>
                </td>
	</tr>
			<?php
			}
		}
	?>
	<?php if (UserModule::doCaptcha('registration')): ?>
	<tr>
		<td>
                    <div align="right"><?php echo $form->labelEx($model,'verifyCode'); ?></div> 
                </td>
		<td>
                    <?php echo $form->textField($model,'verifyCode'); ?>	
                    <?php $this->widget('CCaptcha'); ?>
                    <?php echo $form->error($model,'verifyCode'); ?>
                </td>
	</tr>
        <tr>
        <td>
                
            </td>
            <td>   
            <p class="hint"><?php echo UserModule::t("Please enter the letters as they are shown in the image above."); ?>
            <br/><?php echo UserModule::t("Letters are not case-sensitive."); ?></p>
        </td>
	</tr>
        
	<?php endif; ?>
	<tr>
	<td colspan="2">
	<?php echo CHtml::submitButton(UserModule::t("Register")); ?>
	</td>
	</tr>
</table>
<?php $this->endWidget(); ?>
</div><!-- form -->
</div>
<?php endif; ?>